from Crypto.Cipher import AES
from base64 import b64encode, b64decode
from Crypto import Random

key = b'\xa9\x87J\xfd-\xc9\xf4\xbf\x11\x9dyq\x11\x07Z\x86'
iv = b'\xc9\x95\x93\x14\x18\xe7f\x08\xc6\x849\xc5\xf8\xec\x8f\xf4'

def config_encrypt(plain_text):
    aes = AES.new(key, AES.MODE_CFB, iv)
    cipher = aes.encrypt(plain_text.encode("utf-8"))
    cipher_text = b64encode(cipher).decode()
    return cipher_text


def config_decrypt(cipher_text):
    aes = AES.new(key, AES.MODE_CFB, iv)
    cipher = b64decode(cipher_text)
    plain = aes.decrypt(cipher).decode()
    return plain


if __name__ == '__main__':
    plain_text = 'This  is a secret message'
    t = config_encrypt(plain_text)
    print(t)

    print(config_decrypt(t))